package uz.edo.db.manager;

import uz.edo.db.bean.Reference;
import uz.edo.db.manager.core.DBManager;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: said
 * Date: 1/16/12
 * Time: 11:14 AM
 * To change this template use File | Settings | File Templates.
 */
public class ReferenceManager extends DBManager{
    private static ReferenceManager instance = new ReferenceManager();

    public static ReferenceManager getInstance() {
        return instance;
    }

    public ReferenceManager() {
        super(Reference.class);
    }

    public List<Reference> getParentReferences() throws Exception {
        return createQuery("from Reference r where r.parent is null").list();
    }

    public List<Reference> getReferences(Reference reference) throws Exception {
        return createQuery("from Reference r where r.parent = :reference").setParameter("reference",reference).list();
    }
}
